package leetcode;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * 描述:78. 子集
 *
 * @author Madison You
 * @created 0:04
 */
public class Mid_78_Subsets {
    public static void main(String[] args) {
        int[] ints = {1,2,3};
        new Mid_78_Subsets().subsets(ints);
    }

    List<List<Integer>> list = new ArrayList<>();

    List<Integer> tmp = new ArrayList<>();

    public List<List<Integer>> subsets(int[] nums) {
        back(nums,0);
        return list;
    }

    public void back(int[] nums,int u){
        list.add(new ArrayList<>(tmp));
        for (int i = u; i < nums.length; i++) {
            tmp.add(nums[i]);
            back(nums, i + 1);
            tmp.remove(tmp.size() - 1);
        }
    }

}
